/* Copyright (c) Oracle Corporation 1992.  All Rights Reserved */
/*****************************************************************************
  NAME
    rsf72.ins - Win95 V3 installation script for ORACLE Required Support Files.

  DESCRIPTION
    This script installs the RSF files.

  OWNER

  MODIFIED    DD-MMM-YY Reason

*****************************************************************************/
{
  /**************************************************************************
      Start main logic...
   **************************************************************************/

  if (doit)
    {
      ins_ratchet = "7.2.2.3.1";

      execute("%installer_home%\win95.ins");
     
      permit_retry_operations = FALSE;

      ui_action( instantiate(installing_sys) );
      while(not(empty(copy_list)))
      {
        file_to_copy = first(copy_list);
	{ copy(sys, file_to_copy); }
        ['default: continue();]
        copy_list = rest(copy_list);
      }
      permit_retry_operations = TRUE;

      ui_action(instantiate(installing_scripts));
      copy(deinstl);

      ui_action(instantiate(installing_dlls));

      /*******************************************************************
            Install DLLs
       *******************************************************************/

      tmplist = bin_overwrite;
      while(not(empty(tmplist)))
        {
          filename = first(explode(first(tmplist),"."));
          move_file("%filename%.dll","%filename%.tmp");
          tmplist = rest(tmplist);          
        } 

      copy(dll);

      {
        while(not(empty(bin_overwrite))) 
          {
            filename = first(explode(first(bin_overwrite),"."));
            copy_file("%filename%.tmp","%filename%.dll");
            remove_file("%filename%.tmp");
            bin_overwrite = rest(bin_overwrite);
          }
        while(not(empty(path_overwrite)))
          {
            filename = file_name(first(path_overwrite));
            copy_file(first(path_overwrite),"%oracle_home%\bin\%filename%");
            path_overwrite = rest(path_overwrite);
          }
      }  
         [ 'PERMISSION_DENIED:
           {
             error = permission_denied;
             information_dialog(instantiate(cannot_copy));
             signal('CANNOT_COPY,installation_aborted);
           }
          'OS_ERROR:
           {
             error = os_error;
             information_dialog(instantiate(cannot_copy));
             signal('CANNOT_COPY,installation_aborted);
           }
          'WRITE_ERROR:
           {
             error = write_error;
             information_dialog(instantiate(cannot_copy));
             signal('CANNOT_COPY,installation_aborted);
           }
         ]

      ui_action(instantiate(installing_nls));
      copy(nlsfiles);

      ui_action(instantiate(installing_sql));
      copy(sql);

      ui_action(instantiate(installing_msbs));
      copy(msg, nls_abbreviation);



      /**********************************************************************
          Rename the extra copies of DLLs user selected
       **********************************************************************/

      permit_retry_operations = FALSE;
      /* set to false because the while loop causes the retry dialog to reappear
        even though the user selects ignore */
      while(not(empty(rename_list)))
        {
         tmplist = first(rename_list);
         rename_list = rest(rename_list);
         while (not(empty(tmplist)))
           {
             old_dll = first(tmplist);
             tmplist = rest(tmplist);
             old_dll_dir = directory_name(old_dll);
             filebase = first(explode(file_name(old_dll),"."));
             target_old = replace("%old_dll_dir%\%filebase%.OLD", "\\", "\");
             move_file(old_dll,target_old); /* rename */
             if (exists(old_dll))
               signal('PERMISSION_DENIED,"");
           } [ 'PERMISSION_DENIED:
             {
               error = permission_denied;
               information_dialog(instantiate(cannot_rename));
               signal('CANNOT_RENAME,installation_aborted);
             }
               'OS_ERROR:
             {
               error = os_error;
               information_dialog(instantiate(cannot_rename));
               signal('CANNOT_RENAME,installation_aborted);
             }
               'WRITE_ERROR:
             {
               error = write_error;
               information_dialog(instantiate(cannot_rename));
               signal('CANNOT_RENAME,installation_aborted);
             } ]
        }
        /*******************************************************************
             Document those extra copies user decide not to rename
        ********************************************************************/

        while(not(empty(write_to_file_list)))
          {  
            tmplist = first(write_to_file_list);
            write_to_file_list = rest(write_to_file_list);
            ui_action(instantiate(writing_dlls_txt));
            if (old_dlls_txt=="")
              { /* if file not started */
                old_dlls_txt = "%oracle_home%\rsf_dlls.txt"; /* if not, delete any previous */
                remove_file(old_dlls_txt); /* versions of this file */
                modify("",instantiate(head_message),old_dlls_txt);
              }
              modify("","",old_dlls_txt);
              modify("","-------------------------------------------------------------", old_dlls_txt);
              modify("",instantiate(header_message),old_dlls_txt);
              modify("","",old_dlls_txt);
 
              while (not(empty(tmplist)))
                {
                  current = first(tmplist);
                  tmplist = rest(tmplist);
                  modify("",current,old_dlls_txt);
                }
              modify("","-------------------------------------------------------------",old_dlls_txt);
          } [ 'PERMISSION_DENIED,'WRITE_ERROR,'OS_ERROR:
              /* can't modify old_dlls_txt */
              {
                information_dialog(instantiate(mod_problem),
                                   mod_content,
                                   instantiate(mod_help));
                break();
              }
            ]
       permit_retry_operations = TRUE;
       /**********************************************************************
          Continue with the installation.  Modify Config...
        **********************************************************************/

       if (set_rdbms72)
         {
           ui_action(instantiate(modifying_config));
	   modify("RDBMS72",rdbms72,ora_config,(product_filename(current_product)));
         }

       if (set_plsql22)
         {
           ui_action(instantiate(modifying_config));
	   modify("PLSQL22",plsql22,ora_config,(product_filename(current_product)));
         }

       if (set_pro17)
         {
           ui_action(instantiate(modifying_config));
           modify("PRO17",pro17,ora_config,(product_filename(current_product)));
         }

       if (set_nlsrtl31)
         {
           ui_action(instantiate(modifying_config));
           modify("NLSRTL31",nlsrtl31,ora_config,(product_filename(current_product)));
         }

       if (set_ora_nls)
         {
           ui_action(instantiate(modifying_config));
           modify("ORA_NLS",ora_nls,ora_config,(product_filename(current_product)));
         }

       ui_action(instantiate(registering));
       register(current_product);
       if (member(selected_products,current_product))
         reference(current_product);

    /**************************************************************************
      Add BIN to path?...
    **************************************************************************/

    if (add_bin_to_path)
      {
        ui_action(identifying_bt_drive);
        boot_drive = first(explode(nt_system_root(),":"));

        autoexec_bat = "%boot_drive%:\AUTOEXEC.BAT";
        autoexec_old = "%boot_drive%:\AUTOEXEC.OLD";

        if (exists(autoexec_bat))
          copy_file(autoexec_bat,autoexec_old);
        else
          create_file(autoexec_bat);
          
        permit_retry_operations = FALSE;
        {
          path_variable = "SET PATH";
          separator = " = ";
          autoexec_path = translate(path_variable,autoexec_bat,separator);
        } [ 'UNBOUND_ENVIRONMENT_VARIABLE:
           {
             path_variable = "PATH";
             {
               autoexec_path = translate(path_variable,
                                         autoexec_bat,separator);
             } [ 'UNBOUND_ENVIRONMENT_VARIABLE:
                {
                  separator = " ";
                  {
                    autoexec_path = translate(path_variable,autoexec_bat,
                                              separator);
                  } [ 'UNBOUND_ENVIRONMENT_VARIABLE:
                     {
                       autoexec_path = "";
                       continue();
                     } ]
                } ]
           } ]
        permit_retry_operations = TRUE;
        if (member(explode(autoexec_path,";"),oracle_home_bin))
          information_dialog(instantiate(pth_problem_prompt),
                             pth_problem_content,
                             instantiate(pth_problem_help));
        else
          {
            autoexec_path = "%oracle_home_bin%;%autoexec_path%";
            autoexec_path = implode(explode(autoexec_path,";"),";");
            autoexec_path = "%autoexec_path%;";
            len = length(autoexec_path);
            if (len > 127)
              additional_changes_help = grter_path_length;
            else
              additional_changes_help = "";
            modify(path_variable,autoexec_path,autoexec_bat,separator);
            signal('FAILURE,autoexec_was_changed);
         }
      }
    permit_retry_operations = FALSE;
    }
}
